﻿#include<new>
#include<iostream>
#include"IntArray.h"

using namespace std;

void f(int size, int num) {
	try {
		IntArray x(size);
		for (int i = 0; i < num; i++) {
			x[i] = i;
			cout << "x[" << i << "]=" << x[i] << '\n';
		}
	}
	catch (IntArray::IdxRngErr& x) {
		cout << "下标溢出：" << x.index() << '\n';
		return;
	}
	catch (bad_alloc) {
		cout << "内存分配失败\n";
		exit(1);
	}
}

int main() {
	int size, num;
	cout << "元素个数：";
	cin >> size;

	cout << "数据个数：";
	cin >> num;

	f(size, num);

	cout << "main函数结束\n";

	cin.get();
	cin.get();

}